### misc stuff

import sys
from combinatorial import concat

def debug(*x,**a):
	sys.stderr.write("DEBUG: %s\n" % " ".join(concat((repr(v) for v in x),(" ".join("%s=%s" % (k,repr(v)) for (k,v) in a.iteritems())))))

def read_ints():
	return [int(x) for x in raw_input().strip().split()]

def setup_io():
	fn_in='-'
	fn_out='-'
	if len(sys.argv)==3:
		fn_in=sys.argv[1]
		fn_out=sys.argv[2]
	elif len(sys.argv)==2:
		fn_in=sys.argv[1]
		if fn_in[-3:].lower()=='.in':
			fn_out=fn_in[:-3]+'.out'
		elif fn_in=='-':
			fn_out='-'
		else:
			fn_out=fn_in+'.out'
	if fn_in!='-':
		sys.stdin=open(fn_in,'r')
	else:
		fn_in='<stdin>'
	if fn_out!='-':
		sys.stdout=open(fn_out,'w')
	else:
		fn_out='<stdout>'
	debug(input_file=fn_in,output_file=fn_out)

def auto_zip():
	import zipfile
	zipfn=sys.modules['__main__'].__file__
	if zipfn[-3:]=='.py':
		zipfn=zipfn[:-3]+'.zip'
	elif zipfn[-4:]=='.pyc':
		zipfn=zipfn[:-4]+'.zip'
	else:
		zipfn+='.zip'
	try:
		zipf=zipfile.ZipFile(zipfn,'w',zipfile.ZIP_DEFLATED)
	except:
		zipf=zipfile.ZipFile(zipfn,'w')
	debug(zipping_to_file=zipfn)
	for name,mod in sys.modules.iteritems():
		try:
			if name=='__main__' or mod.__file__[:3]=='lib':
				fn=mod.__file__
				if fn[-4:]=='.pyc':
					fn=fn[:-1]
				debug(zipping_file=fn)
				zipf.write(fn)
		except AttributeError:
			pass
	zipf.close()
	